import type { AxiosResponse } from "axios";
import type { CreateProjectParams, Project } from "../types/projectTypes";
import request from "../utils/request";

const baseUrl = '/api/projects';

export function getProjects(pageNum: number = 1, pageSize: number = 50): Promise<AxiosResponse<Project[]>> {
    return request.get(`${baseUrl}?per_page=${pageSize}&page=${pageNum}`);
}

export function createProject(data: Partial<CreateProjectParams>) {
    return request.post(baseUrl, data);
}

export function updateProject(id: number, data: Partial<CreateProjectParams>) {
    return request.put(`${baseUrl}/${id}`, data);
}

export function deleteProject(id: number) {
    return request.delete(`${baseUrl}/${id}`);
}
